<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
<head>
<!--
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 -->
  <meta http-equiv="X-UA-Compatible" content="IE=8" />

    <title>A canvas globalCompositeOperation example2</title>
    <meta name="DC.creator" content="Takao Obara">

	<!--[if IE]><script type="text/javascript" src="../excanvas.js"></script><![endif]-->

    <script>
      function boot() {
        draw(document.getElementById('canvas').getContext('2d'));
        draw(document.getElementById('vmlcanvas').getContext('2d'));
      }
      function draw(ctx) {
        ctx.globalCompositeOperation = "destination-over";

        var grad1 = ctx.createLinearGradient(0,0, 100,100);
        grad1.addColorStop(0,    'yellow');
        grad1.addColorStop(0.25, 'red');
        grad1.addColorStop(0.75, 'blue');
        grad1.addColorStop(1,    'limegreen');
        ctx.fillStyle = grad1;
        ctx.fillRect(0,0, 100,100);

        var grad2 = ctx.createRadialGradient(100,100,10,100,100,50);
        grad2.addColorStop(0,    'yellow');
        grad2.addColorStop(0.25, 'red');
        grad2.addColorStop(0.75, 'blue');
        grad2.addColorStop(1,    'limegreen');
        ctx.fillStyle = grad2;
        ctx.fillRect(50,50, 100,100);

        var img1 = new Image();
        img1.onload = function() {
//      alert("img onload");
          var pat1 = ctx.createPattern(img1, "repeat");
          ctx.fillStyle = pat1;
          ctx.fillRect(100,100, 100,100);
        };
        img1.onerror = function() {
          alert("img onerror");
        }
        img1.src = "images/i32.png?" + new Date().getTime();
      }
    </script>
    <style type="text/css">
      body { margin: 20px; font-family: arial,verdana,helvetica; background: #fff;}
      h1 { font-size: 140%; font-weight:normal; color: #036; border-bottom: 1px solid #ccc; }
      canvas { border: 2px solid #000; float: left; margin-right: 20px; margin-bottom: 20px; }
      pre { float:left; display:block; background: rgb(238,238,238); border: 1px dashed #666; padding: 15px 20px; margin: 0 0 10px 0; }
    </style>
  </head>
  <body onload="boot();">
    <h1>A canvas <code>globalCompositeOperation</code> example2</h1>
    <div>
        <canvas id="canvas" width="220" height="220"></canvas>
        <canvas id="vmlcanvas" class="vml" width="220" height="220"></canvas>
      <pre>
function boot() {
  draw(document.getElementById('canvas').getContext('2d'));
  draw(document.getElementById('vmlcanvas').getContext('2d'));
}
function draw(ctx) {
  ctx.globalCompositeOperation = "destination-over";

  var grad1 = ctx.createLinearGradient(0,0, 100,100);
  grad1.addColorStop(0,    'yellow');
  grad1.addColorStop(0.25, 'red');
  grad1.addColorStop(0.75, 'blue');
  grad1.addColorStop(1,    'limegreen');
  ctx.fillStyle = grad1;
  ctx.fillRect(0,0, 100,100);

  var grad2 = ctx.createRadialGradient(100,100,10,100,100,50);
  grad2.addColorStop(0,    'yellow');
  grad2.addColorStop(0.25, 'red');
  grad2.addColorStop(0.75, 'blue');
  grad2.addColorStop(1,    'limegreen');
  ctx.fillStyle = grad2;
  ctx.fillRect(50,50, 100,100);

  var img1 = new Image();
  img1.onload = function() {
//      alert("img onload");
    var pat1 = ctx.createPattern(img1, "repeat");
    ctx.fillStyle = pat1;
    ctx.fillRect(100,100, 100,100);
  };
  img1.onerror = function() {
    alert("img onerror");
  }
  img1.src = "images/i32.png?" + new Date().getTime();
}
      </pre>
    </div>
  </body>
</html>
